package top.jacktgq.wait_notify.guardedSuspension.v2;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;

/**
 * 
 * @Title: Downloader.java 
 * @Package top.jacktgq.wait_notify.guardedSuspension.v1 
 * @Description: 抓取百度搜索首页网页代码
 * @author CandyWall   
 * @date 2020年11月1日 下午6:19:00 
 * @version V1.0
 */
public class Downloader {
	public static List<String> download() {
		List<String> lines = new ArrayList<String>();
		try {
			HttpURLConnection conn = (HttpURLConnection) new URL("https://baidu.com").openConnection();
			try (BufferedReader reader = new BufferedReader(
					new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8))) {
				String line = null;
				while ((line = reader.readLine()) != null) {
					lines.add(line);
				}
			} 
		} catch (Exception e) {
			e.printStackTrace();
		}
		return lines;
	}
}
